import request from '@/utils/request'

export function imageCode() {
  //验证码
  return request({
    method: 'get',
    url: '/image/getCode',
  })
}

export function login(data) {
  //登录
  return request({
    method: 'post',
    url: '/login',
    params: data,
  })
}

//登录成功后的调用
export function tbSysUserAddUserInfo(id) {
  return request({
    method: 'get',
    url: '/tbSysUser/addUserInfo/' + id,
  })
}

export function sign(data) {
  //注册
  return request({
    method: 'post',
    url: '/tbSysUser/register',
    data,
  })
}

export function vali(data) {
  //验证账号
  return request({
    method: 'post',
    url: '/tbSysUser/vali',
    data,
  })
}

export function tbSysSiteQuery() {
  //网站基本信息
  return request({
    method: 'get',
    url: '/tbSysSite/query',
  })
}

export function tbSysAddressQuery() {
  //友情链接
  return request({
    method: 'get',
    url: '/tbSysAddress/query',
  })
}

export function tbSysDictDefinitionQueryEnumList(data) {
  //课程类型
  return request({
    method: 'get',
    url: '/tbSysDictDefinition/queryEnumList',
    params: data,
  })
}

export function tbClassifyQuerySelectByTree(type) {
  //分类
  return request({
    method: 'get',
    url: '/tbClassify/querySelectByTree?type=' + type,
  })
}

export function tbSysAttachmentUpload(data) {
  //系统上传附件
  return request({
    method: 'post',
    url: '/tbSysAttachment/upload',
    data,
  })
}

export function tbSysAttachmentDelete(id) {
  //删除一条系统附件
  return request({
    method: 'post',
    url: '/tbSysAttachment/delete/' + id,
  })
}

export function tbSysAttachmentDownload(id) {
  //系统下载附件
  return request({
    method: 'get',
    url: '/tbSysAttachment/download/' + id,
    headers: {
      //和后端设置的一样 application/octet-stream;
      'Content-Type': 'multipart/form-data;charset=UTF-8',
    },
    responseType: 'blob',
  })
}

//测试base64上传
export function tbSysAttachmentSaveToImgByStr(data) {
  return request({
    method: 'post',
    url: '/tbSysAttachment/saveToImgByStr',
    data,
  })
}

export function tbSysAttachmentQueryPathById(id) {
  //取系统获取文件路径
  return request({
    method: 'get',
    url: '/tbSysAttachment/queryPathById/' + id,
  })
}

//查询资源
export function tbSysAttachmentQuery(data) {
  return request({
    method: 'post',
    url: '/tbSysAttachment/query',
    params: data,
  })
}
//下载pdf(有水印)
export function tbSysAttachmentOpenApiDownloadForWatermark(data) {
  return request({
    method: 'post',
    url: '/tbSysAttachment/openApi/downloadForWatermark',
    params: data,
  })
}

export function mySpaceQuery() {
  //取系统获取文件路径
  return request({
    method: 'get',
    url: '/mySpace/query',
  })
}

export function homeStatHomeInfo() {
  //后台数据列表
  return request({
    method: 'get',
    url: '/homeStat/homeInfo',
  })
}
